<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 TpConsransitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="spring" 	uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="tiles" 	uri="http://tiles.apache.org/tags-tiles" %>
<%@ taglib prefix="c"		uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" 	uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page language="java" pageEncoding="utf-8"%>

<!-- URLs for reports -->
<c:url value="/reports/download" var="downloadUrl"/>
<c:url value="/reports/download/token" var="downloadTokenUrl"/>
<c:url value="/reports/download/progress" var="downloadProgressUrl"/>
<!-- end URLs for reports -->

<script type="text/javascript">
$(document).ready(function(){
	
	setMenuSelection("contracte");
	
    $("#tabContractsCard").kendoTabStrip({
        animation:  {
            open: {
                effects: "fadeIn"
            }
        }
    });	  
    
    $("#printMenu").kendoMenu();
    var prnMenu = $("#printMenu").data("kendoMenu");
    

    initMainComboboxes ();
     
    if (getParameter('pDomain')==null) {
   	 $($("#tabContractsCard").data("kendoTabStrip").items()[0]).attr("style", "display:display");
   	 $($("#tabContractsCard").data("kendoTabStrip").items()[1]).attr("style", "display:display");
   	if ($("#pContractNo").val()==""){
		 //alert("null here");
		 getSeqNoContr();
	 }
   	 }
    
    $("#pRefBranch").kendoComboBox({
    });
    var branchCB = $("#pRefBranch").data("kendoComboBox");
    if (getParameter('pService')!=null) {  branchCB.value("${proxyCurrentUser.userBranchId}"); }
    branchCB.readonly(true);
    	 
     document.getElementById("pChat").readOnly=true;
     
     $("#pCons").kendoComboBox({
     });
     var consCB = $("#pCons").data("kendoComboBox");
     if(consCB.value()==-1)  {consCB.value(parseInt("${proxyCurrentUser.userId}"))};
     consCB.readonly(true);
     
     $("#pPers").kendoDropDownList({
     });
     
     $("#pPers2").kendoDropDownList({
     });
     
     $("#pLivePlace").kendoDropDownList({
     });
     
//      $("#pLivePlace").attr('editable', false);
     
     $("#pPropertyType").kendoDropDownList({
     });
     
     $("#pPropertyTypeJ").kendoDropDownList({
     });
     
     $("#pActivityType").kendoDropDownList({
     });
     
     $("#pActivityTypeJ").kendoDropDownList({
     });
     
     $("#pValPlatCurJ").kendoDropDownList({
     });
     
     $("#pContractDate").kendoDatePicker({
    	 format: "dd.MM.yyyy"
    });
    
    $("#pBank").kendoDropDownList({
    });
    
    $("#pAppRegDateDate").kendoDatePicker({
   	 format: "dd.MM.yyyy"
   });
   
    $("#pHusbandAgeF").kendoDatePicker({
      	 format: "dd.MM.yyyy"
      });
    
//     $('#validators_dateValue_demo [name="pHusbandAgeF"]').kendoDatePicker({
//         format: 'dd.MM.yyyy'
//       });
    
//     var validator = $("#validators_dateValue_demo form").kendoValidator().data("kendoValidator");
    
    $("#pHusbandAgeJ").kendoDatePicker({
      	 format: "dd.MM.yyyy"
      });
    
    $("#pRefCompany").kendoDropDownList();
    
    
    $("#pRegCompanies").kendoDropDownList();
    
    $("#btPersonsList").kendoButton({
        icon: "funnel"
    });

    $("#btPersonsCard").kendoButton({
        icon: "plus"
    });
    
    $("#btPersonsCardSubmit").kendoButton({
        icon: "tick"
    });

    $("#btPersonsCardReset").kendoButton({
        icon: "cancel"
    });
    
    $("#btPersonsCardApply").kendoButton({
        icon: "custom"
    });
    
    $("#btPersonsCardSend").kendoButton({
        icon: "tick"
    });
    
    $("#btPersonsCardSendForElaboration").kendoButton({
        icon: "tick"
    });
    
    $("#btPersonsCardSendForPrint").kendoButton({
        icon: "tick"
    });

    //print report button
// 	 $("#pdfButton").kendoButton({
//          click: downloadPdf
//      });

    
    
//     $("#btPersonsCardAssign").kendoButton({
//         icon: "tick"
//     });

//     if(statusCB.value()!=1) {$("#btPersonsCardAssign").hide();}
    
    $("#btPersonsCardReplayYes").kendoButton({
        icon: "tick"
    });
    $("#btPersonsCardReplayNo").kendoButton({
        icon: "tick"
    });
   

    
    // Set Ramas spre achitare value
    var debt = $("#pAmount").val()-$("#pPrepayment").val();
    $("#pDebt").val(debt);
    
    //  Set Contractat combobox 
    if ($('#pContractat').val()==""){
    	$("#pContractat").val(0);
    }
    if ($("#pContractat").val()=="1"){  
    	$('#checkContractat').attr('checked', true); }

    //  Set Finalizat combobox 
    if ($('#pFinalizat').val()==""){
    	$("#pFinalizat").val(0);
    }
    if ($("#pFinalizat").val()=="1"){  
    	$('#checkFinalizat').attr('checked', true); }

    //  Set Black List combobox 
    if ($('#pBlackList').val()==""){
    	$("#pBlackList").val(0);
    }
    if ($("#pBlackList").val()=="1"){  
    	$('#checkBlackList').attr('checked', true); }
    
//  Set Marinati combobox 
    if ($('#pMarinati').val()==""){
    	$("#pMarinati").val(0);
    }
    if ($("#pMarinati").val()=="1"){  
    	$('#checkMarinati').attr('checked', true); }
    
    //  Set De monitorizatt combobox 
    if ($('#pMonitorizat').val()==""){
    	$("#pMonitorizat").val(0);
    }
    if ($("#pMonitorizat").val()=="1"){  
    	$('#checkMonitor').attr('checked', true); }
    
    //  Set Dosar complet combobox 
    if ($('#pComplet').val()==""){
    	$("#pComplet").val(0);
    }
    if ($("#pComplet").val()=="1"){  
    	$('#checkComp').attr('checked', true); }
    
    //  Set Transmis la finantare combobox
    if ($('#pTransmis').val()==""){
    	$("#pTransmis").val(0);
    }
    if ($("#pTransmis").val()=="1"){  
    	$('#checkTrans').attr('checked', true); }
    
    //  Set Finantat combobox 
    if ($('#pFinantat').val()==""){
    	$("#pFinantat").val(0);
    }
    if ($("#pFinantat").val()=="1"){  
    	$('#checkFin').attr('checked', true); }
    
    //  Set Refuzat combobox 3
    if ($('#pRefuz').val()==""){
    	$("#pRefuz").val(0);
    }
    if ($("#pRefuz").val()=="1"){  
    	$('#checkRef').attr('checked', true); }
    
    //  Set Activity Type comboboxes
//     for (var i=0;i<20;i++){
// 	    if ($('#pAct'+i).val()==""){
// 	    	$("#pAct"+i).val(0);
// 	    }
// 	    if ($("#pAct"+i).val()=="1"){  
// 	    	$('#checkAct'+i).attr('checked', true); } 
//     }
    
    //  Set property Type checkboxes
    for (var i=0;i<10;i++){
	    if ($('#pProp'+i).val()==""){
	    	$("#pProp"+i).val(0);
	    }
	    if ($("#pProp"+i).val()=="1"){  
	    	$('#checkProp'+i).attr('checked', true); } 
    }
    
    //  Set project Type checkboxes
    for (var i=0;i<20;i++){
	    if ($('#pProj'+i).val()==""){
	    	$("#pProj"+i).val(0);
	    }
	    if ($("#pProj"+i).val()=="1"){  
	    	$('#checkProj'+i).attr('checked', true); } 
    }
    
//     //  Set Fizic property Type comboboxes
//     for (var i=0;i<10;i++){
// 	    if ($('#pPropF'+i).val()==""){
// 	    	$("#pPropF"+i).val(0);
// 	    }
// 	    if ($("#pPropF"+i).val()=="1"){  
// 	    	$('#checkPropF'+i).attr('checked', true); } 
//     }
    
    //Set Gajat radiogrup for pers fiz
    $('input:radio[name="pGaj"][value="'+$("#pGajFlg").val()+'"]').attr('checked', true);
    
    $("input[name='pGaj']").change(function() {
    	$("#pGajFlg").val($("input[name=pGaj]:checked").val());
     });
    
  //Set Gajat radiogrup for pers jur
    $('input:radio[name="pGajJ"][value="'+$("#pGajFlgJ").val()+'"]').attr('checked', true);
    
    $("input[name='pGajJ']").change(function() {
    	$("#pGajFlgJ").val($("input[name=pGajJ]:checked").val());
     });
    
  //Set MartialStatus Fiz radiogrup
    $('input:radio[name="pMartial"][value="'+$("#pMartialStatus").val()+'"]').attr('checked', true);
    
    $("input[name='pMartial']").change(function() {
    	$("#pMartialStatus").val($("input[name=pMartial]:checked").val());
     });
    
    //Set Children Fiz radiogrup
    $('input:radio[name="pChF"][value="'+$("#pChildrenF").val()+'"]').attr('checked', true);
    
    $("input[name='pChF']").change(function() {
    	$("#pChildrenF").val($("input[name=pChF]:checked").val());
     });
    
    //Set MartialStatus Jur radiogrup
    $('input:radio[name="pMartialJ"][value="'+$("#pMartialStatusJ").val()+'"]').attr('checked', true);
    
    $("input[name='pMartialJ']").change(function() {
    	$("#pMartialStatusJ").val($("input[name=pMartialJ]:checked").val());
     });
    
    //Set ChildrenJur radiogrup
    $('input:radio[name="pChJ"][value="'+$("#pChildrenJ").val()+'"]').attr('checked', true);
    
    $("input[name='pChJ']").change(function() {
    	$("#pChildrenJ").val($("input[name=pChJ]:checked").val());
     });
    
    //Set CreditHistory radiogrup
    $('input:radio[name="pCredit"][value="'+$("#pCreditHistoryFlg").val()+'"]').attr('checked', true);
    
    $("input[name='pCredit']").change(function() {
    	$("#pCreditHistoryFlg").val($("input[name=pCredit]:checked").val());
     });
    
    //Set Poyitiv_Negativ Crefit history radiogrup
    $('input:radio[name="pCreditHist"][value="'+$("#pPositiveHostoryFlg").val()+'"]').attr('checked', true);
    
    $("input[name='pCreditHist']").change(function() {
    	$("#pPositiveHostoryFlg").val($("input[name=pCreditHist]:checked").val());
     });
    
    //Set CreditHistory radiogrup for Jur pers
    $('input:radio[name="pCreditJ"][value="'+$("#pCreditHistoryFlgJ").val()+'"]').attr('checked', true);
    
    $("input[name='pCreditJ']").change(function() {
    	$("#pCreditHistoryFlgJ").val($("input[name=pCreditJ]:checked").val());
     });
    
    //Set Poyitiv_Negativ Crefit history radiogrup for Jur pers
    $('input:radio[name="pCreditHistJ"][value="'+$("#pPositiveHostoryFlgJ").val()+'"]').attr('checked', true);
    
    $("input[name='pCreditHistJ']").change(function() {
    	$("#pPositiveHostoryFlgJ").val($("input[name=pCreditHistJ]:checked").val());
     });
    
    //Set GarantPerson radiogrup
    $('input:radio[name="pGarant"][value="'+$("#pGarantPersonFlg").val()+'"]').attr('checked', true);
    
    $("input[name='pGarant']").change(function() {
    	$("#pGarantPersonFlg").val($("input[name=pGarant]:checked").val());
     });
    
    //Set AfiateCompanys radiogrup
    $('input:radio[name="pAfiateC"][value="'+$("#pAfiateCompanys").val()+'"]').attr('checked', true);
    
    $("input[name='pAfiateC']").change(function() {
    	$("#pAfiateCompanys").val($("input[name=pAfiateC]:checked").val());
     });
    
    //Set Abroad Legal radiogrup Jur
    $('input:radio[name="pAbrJ"][value="'+$("#pAbrLeglJ").val()+'"]').attr('checked', true);
    
    $("input[name='pAbrJ']").change(function() {
    	$("#pAbrLeglJ").val($("input[name=pAbrJ]:checked").val());
     });
    
    //Set Abroad Legal radiogrup Jur
    $('input:radio[name="pAbrF"][value="'+$("#pAbrLeglF").val()+'"]').attr('checked', true);
    
    $("input[name='pAbrF']").change(function() {
    	$("#pAbrLeglF").val($("input[name=pAbrF]:checked").val());
     });
    
    // Set header Caracteristica
//     if (servicesCB.value()==2) {
//     	$('#hCaracteristica').text("Caracteristica grantului");
//     };
    
//     if (servicesCB.value()==3) {
//     	$('#hCaracteristica').text("Caracteristica subvenţii");
//     };
    
    
    //  Set property Date for acorf aditional
    for (var i=0;i<20;i++){
    	$("#aad"+i).kendoDatePicker({
         	 format: "dd.MM.yyyy"
         });
    	$("#aad"+i).attr("readonly", "readonly");
    }
    
    //  Set kendoDropDownList for ClientFiles
    for (var i=0;i<30;i++){
    	$("#fl"+i).kendoDropDownList();
    	$("#fl"+i).closest(".k-widget").hide();
    }
    
    
// POPUP initialization
		initPopup();

		
		//$('#pHusbandAgeF').attr("readonly", "readonly");
		$('#pHusbandAgeJ').attr("readonly", "readonly");

		
// //-------------print menu
// 	$("#printMenu").kendoMenu();
// 		var prnMenu = $("#printMenu").data("kendoMenu");
// 			if (getParameter('pDomain')!=null){
// 			prnMenu.enable("#pm1", false);
// 			prnMenu.enable("#pm2", false);
			
// 			}
// 			if (statusCB.value()<2){
// 				prnMenu.enable("#pm3", false);
// 				prnMenu.enable("#pm4", false);
// 				prnMenu.enable("#pm5", false);
// 			}	
			
			
		});

	var validator;
	var status;	

function SubmitFormContractCard(pPostOperation){
	
//  	 if (validator.validate()) {
	if (1==1) {
		 console.log("Form Is OK");
		 var formAction = $("#formContractCard").attr( 'action' );
			$("#formContractCard").attr('action', formAction + '?pPostOperation='+pPostOperation);
			$("#formContractCard").submit();
		
     } else {
         //status.text("Oops! There is invalid data in the form.").removeClass("valid").addClass("invalid");
         $("#validationErrorMessage").text("Nu sunt completate toate cimpurile! Verificati!");
    	 console.log("Form Is BAD");
     }
}

//Change Contractat combobox
function changeCheckContractat() {
	if ($('#checkContractat').is(':checked')) {
		$("#pContractat").val(1); 
		} 
	else {
		$("#pContractat").val(0);
	}	
}

//Change Finalizat combobox
function changeCheckFinalizat() {
	if ($('#checkFinalizat').is(':checked')) {
		$("#pFinalizat").val(1); 
		} 
	else {
		$("#pFinalizat").val(0);
	}	
}

//Change BlackList combobox
function changeCheckBlackList() {
	if ($('#checkBlackList').is(':checked')) {
		$("#pBlackList").val(1); 
		} 
	else {
		$("#pBlackList").val(0);
	}	
}

//Change Marinati combobox
function changeCheckMarinati() {
	if ($('#checkMarinati').is(':checked')) {
		$("#pMarinati").val(1); 
		} 
	else {
		$("#pMarinati").val(0);
	}	
}

//Change De Monitorizat combobox
function changeCheckMonitor() {
	if ($('#checkMonitor').is(':checked')) {
		$("#pMonitorizat").val(1); 
		} 
	else {
		$("#pMonitorizat").val(0);
	}	
}

//Change Dosar complet combobox
function changeCheckComp() {
	if ($('#checkComp').is(':checked')) {
		$("#pComplet").val(1); 
		} 
	else {
		$("#pComplet").val(0);
	}	
}

//Change Dosar complet combobox
function changeCheckComp() {
	if ($('#checkComp').is(':checked')) {
		$("#pComplet").val(1); 
		} 
	else {
		$("#pComplet").val(0);
	}	
}

//Change Transmis la finantare combobox
function changeCheckTrans() {
	if ($('#checkTrans').is(':checked')) {
		$("#pTransmis").val(1); 
		} 
	else {
		$("#pTransmis").val(0);
	}	
}

//Change Dosar finanțat combobox
function changeCheckFin() {
	if ($('#checkFin').is(':checked')) {
		$("#pFinantat").val(1); 
		} 
	else {
		$("#pFinantat").val(0);
	}	
}

//Change Dosar refuzat combobox
function changeCheckRef() {
	if ($('#checkRef').is(':checked')) {
		$("#pRefuz").val(1); 
		} 
	else {
		$("#pRefuz").val(0);
	}	
}

//Change  combobox for activity Type
function changeCheckAct(n) {
	if ($('#checkAct'+n).is(':checked')) {
		$("#pAct"+n).val(1); 
		} 
	else {
		$("#pAct"+n).val(0); 
	}	
}

//Change  combobox for property Type
function changeCheckProp(n) {
	if ($('#checkProp'+n).is(':checked')) {
		$("#pProp"+n).val(1); 
		} 
	else {
		$("#pProp"+n).val(0); 
	}	
}

//Change  combobox for Project Type
function changeCheckProj(n) {
	if ($('#checkProj'+n).is(':checked')) {
		$("#pProj"+n).val(1); 
		} 
	else {
		$("#pProj"+n).val(0); 
	}	
}

//Change  combobox for fizic property Type
// function changeCheckPropF(n) {
// 	if ($('#checkPropF'+n).is(':checked')) {
// 		$("#pPropF"+n).val(1); 
// 		} 
// 	else {
// 		$("#pPropF"+n).val(0); 
// 	}	
// }
	function changeDebtAmount() {
		var amt  = parseInt($("#pConsultatia").val());
		var debt = amt-parseInt($("#pPrepayment").val());
    $("#pDebt").val(debt);
    $("#pAmount").val(amt);
	}
	
	function nvl(field) {
		var a;
		if ($(field).isNull())
			{
			  a='0';
			}
			else
			{
			  a=parseInt($(field).val());
			}
		return a;
	}
	
	function calcECAmount() {
		var amt=0;
		if ($("#pecRul1").val().length)
		{
			amt+=parseInt($("#pecRul1").val());
		}
		if ($("#pecRul2").val().length)
		{
			amt+=parseInt($("#pecRul2").val());
		}
		if ($("#pecRul3").val().length)
		{
			amt+=parseInt($("#pecRul3").val());
		}
		if ($("#pecRul4").val().length)
		{
			amt+=parseInt($("#pecRul4").val());
		}
		if ($("#pecRul5").val().length)
		{
			amt+=parseInt($("#pecRul5").val());
		}
		if ($("#pecRul6").val().length)
		{
			amt+=parseInt($("#pecRul6").val());
		}
		
		if ($("#pecRegsub").val().length)
		{
			amt+=parseInt($("#pecRegsub").val());
		}
		if ($("#pecAddact").val().length)
		{
			amt+=parseInt($("#pecAddact").val());
		}
		if ($("#pecRegcasa").val().length)
		{
			amt+=parseInt($("#pecRegcasa").val());
		}
		if ($("#pecRegcont").val().length)
		{
			amt+=parseInt($("#pecRegcont").val());
		}
		if ($("#pecCons").val().length)
		{
			amt+=parseInt($("#pecCons").val());
		}
		if ($("#pecContr").val().length)
		{
			amt+=parseInt($("#pecContr").val());
		}
		if ($("#pecAlte").val().length)
		{
			amt+=parseInt($("#pecAlte").val());
		}
		//var amt  = parseInt($("#pecRul1").val())+parseInt($("#pecRul2").val())+parseInt($("#pecRul3").val());
		//var amt  = nvl("#pecRul1")+nvl("#pecRul2")+nvl("#pecRul3");
		
// 		var debt = amt-parseInt($("#pPrepayment").val());
    $("#pecTotal").val(amt);
	}

//report print function
	function downloadPdf() {download('pdf');}
	
	function download(type) {
		// Retrieve download token
		// When token is received, proceed with download
		$.get('${downloadTokenUrl}', function(response) {
			// Store token
			var token = response.message[0];
			
			// Show progress dialog
			$("#testWindow").text('Processing download...');
			
			 $("#testWindow").kendoWindow({
		        width: "300px",
		        title: "Progress...",
				actions: ["Close"]
			 });

			// Start download
			var win=window.open('${downloadUrl}'+'?token='+token+'&type='+type ,+ 'pId=' + $('#pId').val(), '_blank');
			  	win.focus();
 			
			// Check periodically if download has started
			var frequency = 1000;
			var timer = setInterval(function() {
				$.get('${downloadProgressUrl}', {token: token}, 
						function(response) {
							// If token is not returned, download has started
							// Close progress dialog if started
							if (response.message[0] != token) {
								//$('#msgbox').dialog('close');
								$("#testWindow").data("kendoWindow").close();
								clearInterval(timer);
							}
					});
			}, frequency);
			
		});
	}

	
	function uploadFile(pathF){
// 		alert('Start Upload');
		 var form = new FormData(document.getElementById('idUploadFileForm'));
 		 form.append( 'file', $( '#idUserFile' )[0].files[0] );
//		 form.append( 'file', $( '#idUserFile' ).files );
		 $.ajax({
		  url: "f/uploadFile",
		  data: form,
		  dataType: 'text',
		  processData: false,
		  contentType: false,
		  type: 'POST',
		  success: function (response) {
		      var data = jQuery.parseJSON(response);   
// 		      alert(response);
		      
		      var table = document.getElementById("fileTable");
		      var rowCount = table.rows.length;
		      var row = table.insertRow(rowCount);
		      var cell1 = row.insertCell(0);
		      var cell2 = row.insertCell(1);
		      var cell3 = row.insertCell(2);
		      var cell4 = row.insertCell(3);
		      cell1.innerHTML = rowCount;
		      rowCount=rowCount-1;

		      cell2.innerHTML = '<a href="f/downlodFileById?pId='+response+'">'+document.getElementById("idUserFile").value+'</a>'
 		      +'<input id="fl'+rowCount+'.'+pathF+'" name="'+pathF+'['+rowCount+'].id" type="hidden">'
 		      +'<input id="fl'+rowCount+'.'+pathF+'.dBStoredFile" name="'+pathF+'['+rowCount+'].dBStoredFile.id" type="hidden" value="'+response+'">';
 		      
 		      cell3.innerHTML = '<select id="fl'+rowCount+'" name="'+pathF+'['+rowCount+'].refDomains.id" style="width: 300px; display: none;" data-role="dropdownlist"></select>'; 		 	
 		      
 		      cell4.innerHTML ='<button id="btDeleteFile'+rowCount+'" type="button" onclick="deleteFile('+rowCount+');">Șterge Fişier</button>';
 		      
 		      $("#fl"+rowCount).kendoDropDownList();
 	 		
 	 	    $("#fl"+rowCount).kendoDropDownList({dataSource: {
 	 	        type: "json",
 	 	        transport: {
 	 	            read: {
 	 	           	 url: "json/listRefDomainsCBX"
 	 	            }
 	 	        }
 	 	    },
 	 	    index: 2,
 	 		dataTextField: "mdValue",
 	 	    dataValueField: "id"
 	 	    });
 	 	    
		  },
		  error: function (jqXHR) {
		   //Error handling
		  }
		 });
	}

// 	function delFile(){
// 		var table = document.getElementById("fileTable");
// 		var rowCount = table.rows.length;
// 		table.deleteRow(rowCount-1);
// 	}
	
	function deleteFile(rownum){
		var table = document.getElementById("fileTable");
		table.deleteRow(rownum+1);
	}
				
// // 		tds = document.getElementById('fileTable').getElementsByTagName('td');
// // 		rowCount=1;
// // 		tds[4].innerHTML=
// // 	      '<input id="fl'+rowCount+'.applicationFiles" name="applicationFiles['+rowCount+'].id" type="hidden" value="">'
// // 		      +'<input id="fl'+rowCount+'.applicationFiles.dBStoredFile" name="applicationFiles['+rowCount+'].dBStoredFile.id" type="hidden" value="">';
// // ;
// 	}
	
	


	

</script>

<CENTER>
<p style="text-align: left;">
<!-- 	<button id="btPersonsList" type="button" onclick="javascript:window.open('vizualizeazaContracte', target='_self')";>Lista contractelor</button> -->
<!-- 	<button id="btPersonsCard" type="button" onclick="javascript:window.open('adaugaContract', 		target='_self')";>Adaugă contract</button> -->
	<c:if test="${errorMessage != '' &&  errorMessage != '0'}">
		<span id="errorMessage" class="errorMessage"> ${errorMessage} </span>
	</c:if>
</p>



<form:form id="formContractCard" method="post" commandName="contractItem" action="adaugaContract">

<table width="100%">
<tr>
<td width="92%">
<ul class="forms" style="font-size: 14px;">
<p>
	<label  for="pRefDomains" class="required" >Domenii de activitate:   </label> 
	<form:select id="pRefDomains"  path="refDomains.id" style="width:300px;" >
		     	<form:options items="${refDomainsCBX}" itemValue="id" itemLabel="mdValue"/>
	</form:select>	
</p>

<p>	
	<label  for="pRefServices" class="required" >Servicii:   </label>
	<form:select id="pRefServices" path="refServices.id" style="width:300px;"  >
		  <form:options items="${refServicesCBX}" itemValue="id" itemLabel="mdValue"/>
	</form:select>	
</p>

<p>	
	<label  for="pRefPerson" class="required" >Persoana fizică sau juridică:   </label>
	<form:select id="pRefPerson" path="personFlg" style="width:300px;"  >
		<form:options items="${refPersonTypeCBX}" itemValue="id" itemLabel="mdValue"/>
<!-- 		<option value="1" label="Persoana fizică" ></option> -->
<!-- 		<option value="2" label="Persoana juridică" ></option> -->
	</form:select>	
</p>

<p>	
	<label  for="pRefBranch" class="required" >Filiala:   </label>
	<form:select id="pRefBranch" path="refBranch.id" style="width:300px;"  >
		  <form:options items="${refBranchCBX}" itemValue="id" itemLabel="mdValue"/>
	</form:select>	
</p>
</ul>
</td>
<td valign="top">
<div >
                <ul id="printMenu">
                    <li class="k-item k-state-default">
                        Tiparire
                        <ul>
                            <li id="pm1" class="k-link" onclick="prn('ancheta');">Ancheta</li>
                            <li id="pm3" class="k-link" onclick="prn('contract');">Contract</li>
<!--                             <li id="pm4" class="k-link" onclick="prn('acord');">Acord aditional la contract</li> -->
                            <li id="pm5" class="k-link" onclick="prn('act');">Act de predare - primire</li>
                            <li id="pm6" class="k-link" onclick="prn('cont');">Cont de plata</li>
                            <li id="pm9" class="k-link" onclick="prn('chitanta');">Chitanta</li>
                            <li id="pm7" class="k-link" onclick="prn('fisc');">Factura fiscala</li>
                            <li id="pm8" class="k-link" onclick="prn('transp');">Factura de transportare</li>
                            
                        </ul>
                    </li>
                 </ul>
                 </div>
                 



</td>
</tr>
</table>

<div id="tabContractsCard" style="text-align: left;" >
	<ul>
	    <li class="k-state-active">
	              Părţile contractante
	    </li>
	    <li>
	              Obiectul contractului
	    </li>
	    <li>
	              Ancheta persoanei fizice
	    </li>
	    <li>
	              Ancheta persoanei juridice
	    </li>
	    <li>
	              Decizia
	    </li>
	    <li>
	              Fişiere anexate
	    </li>
	</ul> 
	<div>
			<div class="k-block k-shadow">
				<ul class="forms" style="font-size: 14px;">
					

					<div class="k-block"><div class="k-header k-shadow">Persoana fizică:</div>
					
						<form:hidden id="cId" path="regPersons.id" name="id"/>
					<li>
						<label  for="cIdnp" class="required">Cod personal: </label> 		<form:input type="text" id="cIdnp" 	 		path="regPersons.idnp"  		name="cIdnp" 	maxlength="13" style="width:150px;" class="k-textbox"/> 
						<div id="ShowPFSelectPopupCONTRACT" class="k-button">...</div>
						<div id="ShowPFAddPopupCONTRACT" 	class="k-button">+</div>

<!-- 					</li><li> -->
<%-- 						<label  for="cLastName" class="required">Nume: </label> 			<form:input type="text" id="cLastName" 		path="regPersons.lastName"  	name="cLastName" style="width:250px;"  class="k-textbox"/> --%>
<!-- 					</li><li> -->
<%-- 						<label  for="cFirstName" class="required">Prenume: </label> 		<form:input type="text" id="cFirstName" 	path="regPersons.firstName" 	name="cFirstName" style="width:250px;"  class="k-textbox"/> --%>
<!-- 					</li><li>							   -->
<%-- 						<label  for="cPatronymic" class="required">Patronimic:  </label> 	<form:input type="text" id="cPatronymic" 	path="regPersons.patronymic"  	name="cPatronymic" style="width:250px;"  class="k-textbox"/>  --%>
						</li>
						<li>
						<div class="k-block">
						<table width="78%" ><tr><td width="250px">&nbsp;</td><td>
						<b>Nume:</b><form:input type="text" id="cLastName"  path="regPersons.lastName"  	style="width:150px;"  class="k-textbox"/>
 						</td><td>
						<b>Prenume: </b><form:input type="text" id="cFirstName" path="regPersons.firstName" 	style="width:150px;"  class="k-textbox" />
						</td><td>							  
						<b>Patronimic:  </b><form:input type="text" id="cPatronymic" path="regPersons.patronymic"  	 style="width:150px;"  class="k-textbox"/> 
						</td></tr></table>
						</div>
						</li>
					</li>
					</div>
					<br>
					<div class="k-block"><div class="k-header k-shadow">Persoana Juridică:</div>
					
					<form:hidden id="cpId" path="regCompanies.id" name="cpId"/>
					<li>
						<label  for="cpIdno" class="required">Cod fiscal: </label> 			<form:input type="text" id="cpIdno" path="regCompanies.idno" maxlength="13" style="width:150px;" class="k-textbox" />
						<div id="ShowPJSelectPopupCONTRACT" class="k-button">...</div>
						<div id="ShowPJAddPopupCONTRACT" 	class="k-button">+</div>

					</li><li>
						<label  for="cpCompanyName" class="required">Denumire firmă: </label> <form:input type="text" id="cpCompanyName" path="regCompanies.companyName" style="width:250px;"  class="k-textbox" />
					</li>
					
					</div>
				</ul>
			</div>
			</div>
			
			<div>
				<div class="k-block k-shadow">
					<ul class="forms" style="font-size: 14px;">
					<form:hidden id="pIdContract" path="id"/>
					<div class="k-block"><div class="k-header k-shadow">Datele despre contract</div>
						<li>
							<label  for="pContractNo" class="required">Numarul contractului: </label> 		<form:input type="text" id="pContractNo" 	 		path="contractNo"  		name="pContractNo" 	maxlength="13" style="width:150px;" class="k-textbox"/> 
						</li>
						<li>
							<label  for="pContractDate" class="required">Data contractului: </label> 			<form:input type="text" id="pContractDate" 		path="contractDate"  	name="pContractDate" style="width:250px;"  class="k-textbox" data-role="datepicker" role="textbox"/>
						</li>
						<li>	
							<label  for="pRefCompany" >Compania:   </label> 
							<form:select id="pRefCompany" path="refCompany.id" style="width:300px;" >
			     					<form:options items="${refCompanyCBX}" itemValue="id" itemLabel="mdValue"/>
			   				</form:select>					
						</li>
					</div>
					
<!-- 					<div class="k-block"><div id="hCaracteristica" class="k-header k-shadow">Caracteristica serviciu</div> -->
<!-- 						<li> -->
<%-- 							<label  for="pSuma" class="required">Suma: </label> 		<form:input type="text" id="pSuma" 	 		path="suma"  		name="pSuma" 	maxlength="10" style="width:150px;" class="k-textbox"  onchange="changeDebtAmount();"/>  --%>
<!-- 						</li> -->
<!-- 						<li> -->
<%-- 							<label  for="pDestinatia" class="required">Destinaţia: </label> 		<form:input type="text" id="pDestinatia" 	 		path="destinatia"  		name="pDestinatia" 	maxlength="250" style="width:600px;" class="k-textbox"/>  --%>
<!-- 						</li>	 -->
<!-- 					</div> -->
					
					<div class="k-block"><div class="k-header k-shadow">Costul serviciilor</div>
						<li>
							<label  for="pConsultatia"  class="required">Consultaţia: </label> 		<form:input type="text" id="pConsultatia" 	 		path="consultatia"  		name="pConsultatia" 	maxlength="10" style="width:150px;" class="k-textbox"  onchange="changeDebtAmount();"/> 
						</li>
<!-- 						<li> -->
<%-- 							<label  for="pIntermediere"  class="required">Intermediere, %: </label> 		<form:input type="text" id="pIntermediere" 	 		path="intermediere"  		name="pIntermediere" 	maxlength="5" style="width:150px;" class="k-textbox"  onchange="changeDebtAmount();"/>  --%>
<!-- 						</li> -->
					</div>

					<div class="k-block"><div class="k-header k-shadow">Achitarea</div>
						<li>
							<label  for="pPrepayment"  class="required">Avans primit (lei): </label> 		<form:input type="text" id="pPrepayment" 	 		path="prepayment"  		name="pPrepayment" 	maxlength="10" style="width:150px;" class="k-textbox" onchange="changeDebtAmount();"/> 
						</li>
						<li>
							<label  for="pDebt">Rămas spre achitare: (lei): </label> 		<input type="text" id="pDebt" 	name="pDebt" 	maxlength="10" style="width:150px;" class="k-textbox" disabled="disabled"/> 
						</li>
						<li>
							<label  for="pAmount" class="required">Total(lei): </label> 		<form:input type="text" id="pAmount" 	 		path="amount"  		name="pAmount" 	maxlength="10" style="width:150px;" class="k-textbox"  disabled="disabled"/> 
						</li>
						<li>
							<label  for="pContractat">Contractat: </label> 		<input type="checkbox" id="checkContractat" 	value="1" 	name="checkContractat" onclick="changeCheckContractat();" />
							<form:input type="text" id="pContractat"	path="contractatFlg"	name="pContractat" style="visibility:collapse;"/>  
						</li>
						<li>
							<label  for="pFinalizat">Finalizat: </label> 		<input type="checkbox" id="checkFinalizat" 	value="1" 	name="checkFinalizat" onclick="changeCheckFinalizat();" />
							<form:input type="text" id="pFinalizat"	path="finalizatFlg"	name="pFinalizat" style="visibility:collapse;"/>  
						</li>
					</div>					
					
					<li>	
						<label  for="pRefStatus" class="required" >Status:   </label> 
 						<form:select id="pRefStatus" path="refStatus.id" style="width:300px;" > 
		     					<form:options items="${refStatusCBX}" itemValue="id" itemLabel="mdValue"/>
 		   				</form:select>					 
 					</li> 									
					</ul>	
				</div>	
			</div>
			
<!-- -----------------------Ancheta persoana fizica			 -->			
			
			<div>
				<div class="k-block k-shadow">
					<ul class="forms" style="font-size: 14px;">
					<div class="k-block"><div class="k-header k-shadow">Datele personale</div>
					<form:hidden id="pApplicationPersFiz" path="applicationPersFiz.id" name="pApplicationPersFiz"/>
<!-- 					<li> -->
<%-- 						<label  for="pNameSurname" class="required">Nume, Prenume: </label> 		<form:input type="text" id="pNameSurname" 	 		path="applicationPersFiz.nameSurname"  		name="pNameSurname" 	maxlength="150" style="width:150px;" class="k-textbox" required="true"/> --%>
						
<!-- 						<div id="ShowPFSelectPopup" class="k-button">...</div> -->
<%-- 						<label  for="pIDNP" class="required">Codul personal: </label> 		<form:input type="text" id="pIDNP" 	 		path="applicationPersFiz.idnp"  		name="pIDNP" 	maxlength="13" style="width:150px;" class="k-textbox" required="true"/>  --%>
<!-- 					</li> -->

					<form:hidden id="pId" path="applicationPersFiz.regPersons.id" name="id"/>
					<li>
						<label  for="pIdnp" class="required">Cod personal: </label> 		<form:input type="text" id="pIdnp" 	 		path="applicationPersFiz.regPersons.idnp"  		name="idnp" 	maxlength="13" style="width:150px;" class="k-textbox"/> 
						<div id="ShowPFSelectPopupANCHETA" class="k-button">...</div>
						<div id="ShowPFAddPopupANCHETA" 	class="k-button">+</div>
<!-- 					<button id="btPpp" type="button" onclick="getRegPersonApp(1120)";>test</button> -->
					</li>
					<li>
					<div class="k-block">
						<table width="78%" ><tr><td width="250px">&nbsp;</td><td>
						<b>Nume:</b><form:input type="text" id="pLastName" 		path="applicationPersFiz.regPersons.lastName"  	name="lastName" style="width:150px;"  class="k-textbox"/>
 						</td><td>
						<b>Prenume: </b><form:input type="text" id="pFirstName" 	path="applicationPersFiz.regPersons.firstName" 	name="firstName" style="width:150px;"  class="k-textbox" />
						</td><td>							  
						<b>Patronimic:  </b><form:input type="text" id="pPatronymic" 	path="applicationPersFiz.regPersons.patronymic"  	name="patronymic" style="width:150px;"  class="k-textbox"/> 
						</td></tr></table>
					</div>
					</li>

					<li>
						<label  for="pBirthDate" class="required">Ziua de naştere:  </label><form:input 				id="pBirthDate" path="applicationPersFiz.regPersons.birthDate"  	name="birthDate"  style="width:150px;"  class="k-textbox"/>
					</li><li>							
						<label  for="pAddress" class="required">Adresa:  </label> 			<form:textarea  type="text" id="pAddress" 	path="applicationPersFiz.regPersons.address"  	name="address" style="width:250px;"  class="k-textbox" ></form:textarea> 
					</li><li>							
						<label  for="pOcupatia" >Ocupaţia clientului:  </label>				<form:input type="text" id="pOcupatia" 		path="applicationPersFiz.regPersons.ocupatia"  	name="ocupatia" class="k-textbox" /> 
					</li>
<!-- 					<li>							 -->
<!-- 						<label  for="pRegCompanies" >Compania:  </label>  -->
<%-- 						<form:select id="pRegCompanies" path="regCompanies.id" style="width:300px;" > --%>
<!-- 							<option value="Select" label=" - Selectati - " ></option> -->
<%-- 		     					<form:options items="${regCompaniesCBX}" itemValue="id" itemLabel="companyName"/> --%>
<%-- 	    				</form:select> 				 --%>
<!-- 					</li> -->
					<li>							
						<label  for="pPhoneHome" >Tel. acasa:  </label> 					<form:input type="text" id="pPhoneHome" 	path="applicationPersFiz.regPersons.phoneHome"  	name="phoneHome" 	style="width:150px;"  class="k-textbox"  /> 
					</li><li>							
						<label  for="pPhoneServ" >Tel. serviciu:  </label> 					<form:input type="text" id="pPhoneServ" 	path="applicationPersFiz.regPersons.phoneServ"  	name="regPersons.phoneServ" 	style="width:150px;"  class="k-textbox"  />
					</li><li>							
						<label  for="pPhoneMob" >Tel. mobil:  </label> 						<form:input type="text" id="pPhoneMob" 		path="applicationPersFiz.regPersons.phoneMob"  	name="phoneMob" 	style="width:150px;"  class="k-textbox"  />										
					</li><li>							
						<label  for="pEmal" >E-mail:  </label> 								<form:input type="text" id="pEmal" 			path="applicationPersFiz.regPersons.emal"  		name="emal" 		style="width:150px;"  class="k-textbox"  /> 
					</li><li>							
						<label  for="pSkype" >Messenger:  </label> 							<form:input type="text" id="pSkype" 		path="applicationPersFiz.regPersons.skype"  		name="skype" 		style="width:150px;"  class="k-textbox"  /> 
					</li> 
					</div>
				
				<br>
				<c:if test="${contractItem.personFlg== 1||param.pPerson==1}">
				
				<div class="k-block"><div class="k-header k-shadow">Informații despre Evidența Contabilă</div>
							<table id="aagree" width="880px">
						    <tr>
						        <th align="left">Denumirea</th>
						        <th align="left">Adresa</th>
						        <th align="left">Numărul cadastral</th>
						        <th align="left">Comentariu</th>

						        
						    </tr>
						    
					</table>
				</div>	
				</c:if>

					
					</ul>	
				</div>
			</div>
			
<!-- -----------------------Ancheta persoana juridica			 -->
			
			<div>
				<div class="k-block k-shadow">
					<ul class="forms" style="font-size: 14px;">
					<div class="k-block"><div class="k-header k-shadow">Datele companie</div>
					<form:hidden id="pApplicationPersJur" path="applicationPersJur.id" name="pApplicationPersJur"/>
<!-- 						<li> -->
<!-- 							<label  for="pName" class="required">Denumire: </label>  -->
<%-- 							<form:input type="text" id="pName" path="applicationPersJur.name"  	name="pName" 	maxlength="250" style="width:200px;" class="k-textbox" required="true"/> --%>


							
<!-- 							<label  for="pIDNO" class="required">IDNO: </label>  -->
<%-- 							<form:input type="text" id="pIDNO" 	 		path="applicationPersJur.idno"  		name="pIDNO" 	maxlength="13" style="width:150px;" class="k-textbox" required="true"/> --%>
<!-- 						</li> -->
<!-- 						<li> -->
<!-- 							<label  for="pAddress" class="required">Adresa: </label>  -->
<%-- 							<form:input type="text" id="pAddress" path="applicationPersJur.address"  	name="pAddress" 	maxlength="250" style="width:200px;" class="k-textbox" required="true"/> --%>

<!-- 							<div id="ShowPJSelectPopup" class="k-button">...</div> -->
<!-- 							<label  for="pIDNO" class="required" style="width: 268px;">IDNO: </label>  -->
<%-- 							<form:input type="text" id="pIDNO" 	 		path="applicationPersJur.idno"  		name="pIDNO" 	maxlength="13" style="width:150px;" class="k-textbox" required="true"/> --%>
<!-- 						</li> -->
<!-- 						<li> -->
<!-- 							<label  for="pAddress" class="required">Adresa: </label>  -->
<%-- 							<form:input type="text" id="pAddress" path="applicationPersJur.address"  	name="pAddress" 	maxlength="250" style="width:200px;" class="k-textbox" required="true"/> --%>
				
							
<!-- 							<label  for="pPhoneJ" class="required">Telefon: </label>  -->
<%-- 							<form:input type="text" id="pPhoneJ" 	 		path="applicationPersJur.phone"  		name="pPhoneJ" 	maxlength="10" style="width:150px;" class="k-textbox" required="true"/>  --%>
							 
<!-- 						</li> -->

				<form:hidden id="ppId" path="applicationPersJur.regCompanies.id" name="ppId"/>
				<li>
					<label  for="ppIdno" class="required">Cod fiscal: </label> 			<form:input type="text" id="ppIdno" 	 				path="applicationPersJur.regCompanies.idno"  				name="ppIdno" 	maxlength="13" style="width:150px;" class="k-textbox" readonly="readonly"/>
					<div id="ShowPJSelectPopupANCHETA" class="k-button">...</div>
					<div id="ShowPJAddPopupANCHETA" 	class="k-button">+</div>
<!-- 					<button id="btPpp" type="button" onclick="getRegCompanysApp(2)";>test</button>  -->
				</li><li>
					<label  for="ppCompanyName" class="required">Denumire firmă: </label> <form:input type="text" id="ppCompanyName" 			path="applicationPersJur.regCompanies.companyName"  		name="ppCompanyName" style="width:250px;"  class="k-textbox"/>
				</li><li>
				<label  for="ppCompanyFondDate">Data fondarii: </label> <form:input type="text" id="ppCompanyFondDate" 			path="applicationPersJur.regCompanies.foundationDate"  		name="ppCompanyFondDate" style="width:150px;"  class="k-textbox"/>
				</li><li>
					<label  for="ppBossNameSurname">Nume, Prenume director: </label><form:input type="text" id="ppBossNameSurname" 	path="applicationPersJur.regCompanies.bossNameSurname" 	name="ppBossNameSurname" style="width:250px;"  class="k-textbox" />
				</li><li>
					<label  for="ppBossBirthDate">Data nașterii directorul: </label><form:input type="text" id="ppBossBirthDate" 	path="applicationPersJur.regCompanies.bossBirthDate" 	name="ppBossBirthDate" style="width:150px;"  class="k-textbox" />

<!-- 				</li><li>	 -->
<!-- 					<label  for="pRegCompanies" >Genul de activitate:   </label>  -->
<%-- 					<form:select id="pRefActivityType" path="refActivityType.id" style="width:300px;" > --%>
<!-- 						<option value="Select" label=" - Selectati - " ></option> -->
<%-- 	     					<form:options items="${refActivityTypeCBX}" itemValue="id" itemLabel="mdValue"/> --%>
<%-- 	   				</form:select>					 --%>
				</li><li>							
					<label  for="ppAddress">Adresa:  </label> 			<form:textarea  type="text" id="ppAddress" 			path="applicationPersJur.regCompanies.address"  			name="ppAddress" style="width:250px;"  class="k-textbox" ></form:textarea> 
				</li><li>							
					<label  for="ppAddressJ">Adresa juridică:  </label> 	<form:textarea  type="text" id="ppAddressJ" 	path="applicationPersJur.regCompanies.juridicAddress"  		name="ppAddressJ" style="width:250px;"  class="k-textbox"  ></form:textarea> 
				</li><li>					
					<label  for="ppPhoneMob" >Tel. mobil:  </label> 						<form:input type="text" id="ppPhoneMob" 				path="applicationPersJur.regCompanies.phoneMob"  			name="ppPhoneMob" 	style="width:150px;"  class="k-textbox"  />										
				</li><li>
					<label  for="ppPhoneServ" >Tel. serviciu:  </label> 					<form:input type="text" id="ppPhoneServ" 			path="applicationPersJur.regCompanies.phoneServ"  			name="ppPhoneServ" 	style="width:150px;"  class="k-textbox"  />
				</li><li>							
					<label  for="ppSkype" >Messenger:  </label> 							<form:input type="text" id="ppSkype" 				path="applicationPersJur.regCompanies.skype"  				name="ppSkype" 		style="width:150px;"  class="k-textbox"  /> 
				</li><li>							
					<label  for="ppEmal" >E-mail:  </label> 								<form:input type="text" id="ppEmal" 					path="applicationPersJur.regCompanies.emal"  				name="ppEmal" 		style="width:150px;"  class="k-textbox"  /> 
				</li><li>							
					<label  for="ppCompanySite"> Site:  </label>							<form:input type="text" id="ppCompanySite" 			path="applicationPersJur.regCompanies.companySite"  		name="ppCompanySite" 		style="width:150px;"  class="k-textbox"  /> 
				</li>
					</div>
					
					<br>
 				<c:if test="${contractItem.personFlg== 2||param.pPerson==2}"> 
 				
					<div class="k-block"><div class="k-header k-shadow">Informații despre Evidența Contabilă</div>
							<table id="aagree" width="880px">
							<tr>
								<td colspan="3" align="center"><b>1) ACTIVITATEA GENERALĂ</b></td>
						    </tr>
						    <tr>
						        <td align="right">cu un rulaj anual  <100 000  lei  fara salariati*</td>
						        <td align="center" width="140px"><b>500</b></td>
						        <td align="left"><form:input type="text" id="pecRul1" path="ecRul1" style="width:150px;" class="k-textbox" onchange="calcECAmount();"/></td>
						    </tr>
						    <tr>
						        <td align="right">cu un rulaj anual  <100 000  lei și  ≤3 salaiati*</td>
						        <td align="center"><b>1500 - 2000**</b></td>
						        <td align="left"><form:input type="text" id="pecRul2" path="ecRul2" style="width:150px;" class="k-textbox" onchange="calcECAmount();"/></td>
						    </tr>
						    <tr>
						        <td align="right">cu un rulaj anual  100 000 - 600 000 lei și  ≤5 salaiati*, neplatitor TVA</td>
						        <td align="center"><b>2500 - 3000**</b></td>
						        <td align="left"><form:input type="text" id="pecRul3" path="ecRul3" style="width:150px;" class="k-textbox" onchange="calcECAmount();"/></td>
						    </tr>
						    <tr>
						        <td align="right">cu un rulaj anual  100 000 - 600 000 lei și  ≤5 salaiati*, platitor TVA</td>
						        <td align="center"><b>4000 - 5000**</b></td>
						        <td align="left"><form:input type="text" id="pecRul4" path="ecRul4" style="width:150px;" class="k-textbox" onchange="calcECAmount();"/></td>
						    </tr>
						    <tr>
						        <td align="right">cu un rulaj > 600 000 lei si ≤10 salaiati*</td>
						        <td align="center"><b>> 5000**</b></td>
						        <td align="left"><form:input type="text" id="pecRul5" path="ecRul5" style="width:150px;" class="k-textbox" onchange="calcECAmount();"/></td>
						    </tr>
						    <tr>
						        <td align="right">*in cazul cind firma detine un numar mai mare de salariati indicat, taxa pentru fiecare angajat va constitui</td>
						        <td align="center"><b>100</b></td>
						        <td align="left"><form:input type="text" id="pecRul6" path="ecRul6" style="width:150px;" class="k-textbox" onchange="calcECAmount();"/></td>
						    </tr>
						    <tr>
						        <td align="right">** tariful se determina in dependenta de volumul și tipul activității: comerț, agricultura,  servicii auto, construcție, asigurări, transport, producere, etc.</td>
						        <td align="left">&nbsp;</td>
						        <td align="left">&nbsp;</td>
						    </tr>
						    <tr>
								<td colspan="3" align="center"><b>2) ACTIVITATEA SUPLIMENTARĂ</b></td>
						    </tr>
						    <tr>
								<td colspan="3" align="center"><b>a) Subdiviziuni & tip nou de activitate </b></td>
						    </tr>
						    <tr>
						        <td align="right">înregistrarea fiecarii subdiviziuni și evidenta lunară</td>
						        <td align="center"><b>500</b></td>
						        <td align="left"><form:input type="text" id="pecRegsub" path="ecRegsub" style="width:150px;" class="k-textbox" onchange="calcECAmount();"/></td>
						    </tr>
						    <tr>
						        <td align="right">adaugarea unui nou tip de activitate (in cazul cind nu este inclusă ca subdiviziune)</td>
						        <td align="center"><b>500</b></td>
						        <td align="left"><form:input type="text" id="pecAddact" path="ecAddact" style="width:150px;" class="k-textbox" onchange="calcECAmount();"/></td>
						    </tr>
						    <tr>
								<td colspan="3" align="center"><b>b) Gestionarea mijloacelor banesti</b></td>
						    </tr>
						    <tr>
						        <td align="right">înregistrarea aparat de casa si evidența lunară</td>
						        <td align="center"><b>500</b></td>
						        <td align="left"><form:input type="text" id="pecRegcasa" path="ecRegcasa" style="width:150px;" class="k-textbox" onchange="calcECAmount();"/></td>
						    </tr>
						    <tr>
						        <td align="right">înregistrarea fiecarui cont de decontare in cazul disponibilitatii > de cit 1  cont de decontare si evidența lunară</td>
						        <td align="center"><b>100</b></td>
						        <td align="left"><form:input type="text" id="pecRegcont" path="ecRegcont" style="width:150px;" class="k-textbox" onchange="calcECAmount();"/></td>
						    </tr>
						    <tr>
								<td colspan="3" align="center"><b>3) ALTELE</b></td>
						    </tr>
						    <tr>
						        <td align="right">consulatnta (după caz)</td>
						        <td align="center"><b> 200 lei/ora </b></td>
						        <td align="left"><form:input type="text" id="pecCons" path="ecCons" style="width:150px;" class="k-textbox" onchange="calcECAmount();"/></td>
						    </tr>
						    <tr>
						        <td align="right">perfectarea contractelor (după caz)</td>
						        <td align="center"><b>300 lei/contract</b></td>
						        <td align="left"><form:input type="text" id="pecContr" path="ecContr" style="width:150px;" class="k-textbox" onchange="calcECAmount();"/></td>
						    </tr>
						    <tr>
						        <td align="right">Alte servicii  se stabilesc dupa caz în dependență de tipul de activitate</td>
						        <td align="center">&nbsp;</td>
						        <td align="left"><form:input type="text" id="pecAlte" path="ecAlte" style="width:150px;" class="k-textbox" onchange="calcECAmount();"/></td>
						    </tr>
						    <tr>
						        <td align="right"><b>TOTAL</b></td>
						        <td align="left">&nbsp;</td>
						        <td align="left"><form:input type="text" id="pecTotal" path="ecTotal" style="width:150px;"  class="k-textbox"  /></td>
						    </tr>
						    
						    
					</table>
				</div>	
					
 				</c:if> 
					
				</ul>	
				</div>
			</div>
<!-- -----------------------Decizia			 --> 
 		<div>
			<div class="k-block k-shadow">
				<ul class="forms" style="font-size: 14px;">
				<div class="k-block"><div class="k-header k-shadow">Datele consultantului</div>
					<li>	
						<label  for="pCons" class="required" >Persoana responsabilă:   </label> 
  						<form:select id="pCons" path="responsConsultant.id" style="width:300px;" > 
 		     					<option value="-1" label=" - Selectati - " ></option>
 		     					<form:options items="${secUserCBX}" itemValue="id" itemLabel="fullName"/> 
  		   				</form:select>	
  		   				</li> 
 						<li>
  		   				<label  for="pAppRegDateDate" class="required">Data inregistrării: </label> <form:input type="text" id="pAppRegDateDate" 		path="appRegDate"  	 style="width:150px;"  class="k-textbox"  required="true" data-role="datepicker" role="textbox"/>				  
 					</li> 	
<!-- 					<li> -->
<%-- 						<label  for="pConsComment" >Comentariu consultantului: </label> 		<form:textarea type="text" id="pConsComment" 	path="consultantComment"  		name="pConsComment" 	maxlength="150" style="width:450px;" class="k-textbox"/>  --%>
<!-- 					</li> -->
				</div>
				<br>
				<div class="k-block"><div class="k-header k-shadow">Agentii</div>	
 					<li>	
						<label  for="pPers" class="required" >Agent 1:   </label> 
  						<form:select id="pPers" path="responsPersonal.id" style="width:300px;" > 
 		     					<option value="-1" label=" - Selectati - " ></option>
 		     					<form:options items="${secUserCBX}" itemValue="id" itemLabel="fullName"/> 
  		   				</form:select>					  
 					</li> 
 					
 					<li>	
						<label  for="pPers2" class="required" >Agent 2:   </label> 
  						<form:select id="pPers2" path="responsPersonal2.id" style="width:300px;" > 
 		     					<option value="-1" label=" - Selectati - " ></option>
 		     					<form:options items="${secUserCBX}" itemValue="id" itemLabel="fullName"/> 
  		   				</form:select>					  
 					</li> 
 					
<!--  					<li> -->
<%-- 						<label  for="pPersComment" >Comentariu personalului: </label> 		<form:textarea type="text" id="pPersComment" 	path="personalComment"  		name="pPersComment" 	maxlength="250" style="width:450px;" class="k-textbox"/>  --%>
<!-- 					</li> -->
					
				
				</div>
				<br>
				<div class="k-block"><div class="k-header k-shadow">Opțiuni</div>
					<li> 
	 					<label  for="pBlackList">De adăugat clientul în "lista neagră": </label> 
	 					<input type="checkbox" id="checkBlackList" 	value="1" onclick="changeCheckBlackList();" /> 
	 					<form:hidden  id="pBlackList"	path="blackListFlg"	/>   
	 					<label  for="pMarinati">Marinați: </label> 
	 					<input type="checkbox" id="checkMarinati" 	value="1" onclick="changeCheckMarinati();" /> 
	 					<form:hidden  id="pMarinati"	path="marinati"	/> 
 					</li> 
 					<br>
 					<li>
	 					<label  for="pMonitorizat">De monitorizat: </label> 
	 					<input type="checkbox" id="checkMonitor" 	value="1"  onclick="changeCheckMonitor();" /> 
	 					<form:hidden id="pMonitorizat"	path="deMonitorizat" />   
	 					<label  for="pMonitorizat">Dosar complet: </label> 
	 					<input type="checkbox" id="checkComp" 	value="1"  onclick="changeCheckComp();" /> 
	 					<form:hidden id="pComplet"	path="dosarComplet"/>
					</li> 
 					<li>
 						<label  for="pTransmis">Dosar transmis la finanțator: </label> 
	 					<input type="checkbox" id="checkTrans" 	value="1"  onclick="changeCheckTrans();" /> 
	 					<form:hidden id="pTransmis"	path="dosarTransmis" />   
	 					<label  for="pFinantat">Dosar finanțat: </label> 
	 					<input type="checkbox" id="checkFin" 	value="1"  onclick="changeCheckFin();" /> 
	 					<form:hidden id="pFinantat"	path="dosarFinantat" />   
					</li> 
 					<li>
						<label  for="pRefuz">Dosar refuzat: </label> 
	 					<input type="checkbox" id="checkRef" 	value="1"  onclick="changeCheckRef();" /> 
	 					<form:hidden id="pRefuz"	path="dosarRefuzat" /> 
					</li>
				</div>
				<br>
<!-- 				<div class="k-block"><div class="k-header k-shadow">Tipuri de proiecte</div> -->
<!--  					<table width="680px"> -->
<!-- 						    <tr> -->
<!-- 						        <th align="right">Tipuri de proiecte:</th> -->
<!-- 						    </tr> -->
<%-- 						    <c:forEach items="${contractItem.applicationProjectType}" var="pt" varStatus="status2"> --%>
<!-- 						        <tr> -->
					            

<%-- 									<td align="right">${pt.refProjectType.mdValue}</td> --%>
<!-- 						            <td> -->
<%-- 						            <form:hidden id="pt${status2.index}.id" path="applicationProjectType[${status2.index}].id" name="pt${status2.index}.id"/> --%>
<%-- 						            <form:hidden id="pt${status2.index}.refProjectType" path="applicationProjectType[${status2.index}].refProjectType.id" name="pt${status2.index}.refProjectType"/> --%>
<%-- 						            <input type="checkbox" id="checkProj${status2.index}" name="checkProj${status2.index}" onclick="changeCheckProj(${status2.index});"/> --%>
<%-- 						            <form:hidden name="pProj${status2.index}" id="pProj${status2.index}"  value="${pt.value}" path="applicationProjectType[${status2.index}].value"/> --%>
<!-- 						            </td> -->
<!-- 						        </tr> -->
<%-- 						    </c:forEach> --%>
<!-- 					</table> -->
<!-- 				</div>	 -->
<!-- 				<br> -->
				<div class="k-block"><div class="k-header k-shadow">Banca</div>
					<li>	
						<label  for="pBank">Banca:  </label>		
						<form:select id="pBank" path="refBank.id" style="width:500px;" >  --%>
 	 		     				<option value="-1" label=" - Selectati - " ></option>  
	 		     				<form:options items="${refBankCBX}" itemValue="id" itemLabel="mdValue"/>  
	  		   			</form:select>	
 	  
 					</li> 	
				</div>
				<br>
				<div class="k-block"><div class="k-header k-shadow">Comentarii</div>
					<li>	
						<label  for="pChat">Comentarii:  </label><form:textarea id="pChat" path="chat" name="chat" style="width:750px;" rows="9" ></form:textarea>				  
 					</li> 	
					<li>
						<label  for="pConsComment" >Introduceti comentariu: </label> 		<form:textarea type="text" id="pConsComment" 	path="consultantComment"  		name="pConsComment" 	maxlength="300" style="width:750px;" class="k-textbox" rows="4"/> 
					</li>
					<p style="text-align: right;">
						<button id="btPersonsCardApply"		type="button" onclick="SubmitFormContractCard('remain')" 	>Trimite comentariu</button>
					</p>
				</div>
 
					
				</ul>
			</div>
			</div>

<!-- -----------------------Fisiere		 --> 
  			<div>
			<div class="k-block k-shadow">
				<ul class="forms" style="font-size: 14px;">
				
				<table id="fileTable" border="0px">
						    <tr>
						        <th align="right">Fişiere:</th>
						    </tr>

						 	<c:set var="dom1" scope="session" value="0"/>
						 	<c:set var="dom2" scope="session" value="0"/>
						 	<c:set var="hr" scope="session" value="0"/>


							<c:choose>
				   			<c:when test="${contractItem.personFlg== 1||param.pPerson==1}">
				   			<c:set var="pathF" scope="session" value="applicationPersFiz.regPersons.clientFiles"/> 
<!-- 1 - from here copypasted 2						     -->
						    <c:forEach items="${contractItem.applicationPersFiz.regPersons.clientFiles}" var="fl" varStatus="statusf">
						    
						    <c:set var="dom2" scope="session"  value="${contractItem.applicationPersFiz.regPersons.clientFiles[statusf.index].refDomains.mdValue}"/>
						    <c:if test="${dom1!=dom2}">
						        <tr><td colspan="4"><b>${dom2}</b><hr width="100%"></td></tr>
						        <c:set var="hr" scope="session" value="${hr+1}"/>
						    </c:if>
						    
						        <tr>
						            <td>
						            	${statusf.count}
						            </td>
						            <td><a href="f/downlodFileById?pId=${fl.dBStoredFile.id}">${fl.dBStoredFile.fileName}</a>
							            <form:hidden id="fl${statusf.index}.${pathF}" path="${pathF}[${statusf.index}].id" name="fl${statusf.index}.${pathF}"/>
							            <form:hidden id="fl${statusf.index}.${pathF}.dBStoredFile" path="${pathF}[${statusf.index}].dBStoredFile.id" name="fl${statusf.index}.${pathF}.dBStoredFile"/>
									</td>
									<td>						            
							            <form:select id="fl${statusf.index}"   path="${pathF}[${statusf.index}].refDomains.id" style="width:300px;" >
		     									<form:options items="${refDomainsCBX}" itemValue="id" itemLabel="mdValue"/>
		   								</form:select>	
	   								</td>
									<td><button id="btDeleteFile${statusf.index}" 	type="button" onclick="deleteFile(this.parentNode.parentNode.rowIndex-1);"	>Șterge Fişier</button></td>
 					        	</tr>
 					        	
 					        	<c:set var="dom1" scope="session"  value="${dom2}"/>
 					        	
						    </c:forEach>
						    
						    <tr><td colspan="4"><hr width="100%"></td></tr>

						    
						    </c:when> 
				  			<c:when test="${contractItem.personFlg== 2||param.pPerson==2}">
							<c:set var="pathF" scope="session" value="applicationPersJur.regCompanies.clientFiles"/>
<!-- 2 copypasted from 1							 -->
							<c:forEach items="${contractItem.applicationPersJur.regCompanies.clientFiles}" var="fl" varStatus="statusf">
							
							<c:set var="dom2" scope="session"  value="${contractItem.applicationPersJur.regCompanies.clientFiles[statusf.index].refDomains.mdValue}"/>
						    <c:if test="${dom1!=dom2}">
						        <tr><td colspan="4"><b>${dom2}</b><hr width="100%"></td></tr>
						        <c:set var="hr" scope="session" value="${hr+1}"/>
						    </c:if>
							
						        <tr>
						            <td>
						            	${statusf.count}
						            </td>
						            <td><a href="f/downlodFileById?pId=${fl.dBStoredFile.id}">${fl.dBStoredFile.fileName}</a>
							            <form:hidden id="fl${statusf.index}.${pathF}" path="${pathF}[${statusf.index}].id" name="fl${statusf.index}.${pathF}"/>
							            <form:hidden id="fl${statusf.index}.${pathF}.dBStoredFile" path="${pathF}[${statusf.index}].dBStoredFile.id" name="fl${statusf.index}.${pathF}.dBStoredFile"/>
									</td>
									<td>						            
							            <form:select id="fl${statusf.index}"   path="${pathF}[${statusf.index}].refDomains.id" style="width:300px;" >
		     									<form:options items="${refDomainsCBX}" itemValue="id" itemLabel="mdValue"/>
		   								</form:select>	
	   								</td>
									<td><button id="btDeleteFile${statusf.index}" 	type="button" onclick="deleteFile(this.parentNode.parentNode.rowIndex-1);"	>Șterge Fişier</button></td>
 					        	</tr>
 					        	
 					        	<c:set var="dom1" scope="session"  value="${dom2}"/>
 					        	
						    </c:forEach>
						    
						    <tr><td colspan="4"><hr width="100%"></td></tr>
						    
							</c:when>
						 	</c:choose>
						</table>
						
						<input id="idUserFile" 			type="file" name="idUserFile" style="height: 20px" />
						<button id="btUploadFile" 		type="button" onclick="uploadFile('${pathF}');"	>Incarca Fişier	</button>
<!-- 						<button id="btDel"		type="button" onclick="delFile();" 	>Șterge Fişier</button> -->
 				</ul>
			</div>
			</div>
 </div>		
 	
			<p style="text-align: right;">
			<span id="validationErrorMessage" class="status" style="color: red; float: left;"></span>
<!-- 				<button id="btPersonsCardApply"		type="button" onclick="SubmitFormContractCard('remain')" 	>Aplică</button> -->
				<button id="btPersonsCardSubmit" 	type="button" onclick="SubmitFormContractCard('remain')"  >Salvează</button>
<!-- 				<button id="btPersonsCardSend" 		type="button" onclick="SubmitFormContractCard('send')"  >Trimite la aprobare</button> -->
				<button id="btPersonsCardSendForElaboration" 		type="button" onclick="SubmitFormContractCard('elab')"  >Trimite la elaborare</button>
				<button id="btPersonsCardSendForPrint" 		type="button" onclick="SubmitFormContractCard('print')"  >Trimite la tipar</button>
<!-- 				<button id="btPersonsCardReplayYes" type="button" onclick="SubmitFormContractCard('replayYes')"  >Decizia pozitivă</button> -->
<!-- 				<button id="btPersonsCardReplayNo" 	type="button" onclick="SubmitFormContractCard('replayNo')"  >Decizia negativă</button> -->
				<button id="btPersonsCardReset" 	type="reset"  onclick="javascript: window.history.back();">Anulează</button>
<!-- 				<button type="button" id="pdfButton">PDF</button> -->
			</p> 		
		

	  

</form:form> 

<form id="idUploadFileForm" enctype="multipart/form-data">
					
</form>    
<!-- 	<div id="window"></div>						 -->


<div id="windowClientiPFListPopup"></div>

<div id="windowClientiPFCardPopup"></div>

<div id="windowClientiPJListPopup"></div>

<div id="windowClientiPJCardPopup"></div>


    
</CENTER>
<style scoped>
     #formContractCard ul {
         list-style-type: none;
         margin: 0;
         padding: 0;
     }
     #formContractCard li {
         margin: 10px 0 0 0;
     }

     label {
         display: inline-block;
         width: 300px;
         text-align: right;
     }
     
/*      input { */
/*      	height: 10px; */
/*      } */

     .required {
         font-weight: bold;
     }

     .accept, .status {
         padding-left: 90px;
     }

     .valid {
         color: green;
     }

     .invalid {
         color: red;
     }
     span.k-tooltip {
         margin-left: 6px;
     }
     
 #printMenu {
         list-style-type: none;
         margin: 0 0 0 0;
         padding: 0;
         height: 40px;
     }
 </style>



